package com.iv.durian.cloud.dao;

import com.iv.durian.cloud.Content;
import com.iv.durian.cloud.Coverage;
import com.iv.durian.cloud.dao.mapper.ContentMapper;
import com.iv.durian.cloud.dao.mapper.CoverageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by LiuLin on 2018/6/30 0030.
 */
@Repository
public class CoverageDao {
    @Autowired
    CoverageMapper coverageMapper;

    @Autowired
    ContentMapper contentMapper;
    public List<Coverage> list(Integer type) {
        return coverageMapper.list(type);
    }

    public Coverage get(Integer coverageId) {
        return coverageMapper.get(coverageId);
    }

    public void add(Coverage coverage) {
        coverageMapper.add(coverage);
        Content content = new Content();
        content.setCoverageId(coverage.getId());
        content.setContent("");
        contentMapper.add(content);
    }

    public int remove(Integer coverageId) {
        contentMapper.remove(coverageId);
        return coverageMapper.remove(coverageId);
    }

    public int count(Integer type) {
        return coverageMapper.count(type);
    }

    public void update(Coverage coverage) {
        coverageMapper.update(coverage);
    }

    public Content getContent(Integer coverageId) {
        return contentMapper.get(coverageId);
    }

    public void updateContent(Content content) {
        contentMapper.update(content);
    }

}
